package com.yanqu.road.server.manger.maidian.embroidroom;

import com.yanqu.road.entity.player.UserColdRoomSite;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.ColdRoomModule;
import com.yanqu.road.server.manger.DataAnalyticsMgr;
import com.yanqu.road.server.manger.maidian.DefaultEventTraceAction;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class EmbroidRoomLog {

    public static final String EMBROID_ROOM = "embroid_room";

    public static final String EMBROID_ID = "embroid_id";
    public static final String EMBROID_BEAUTY = "embroid_beauty";

    public static final String EMBROID_MAX = "embroid_max";
    public static final String EMBROID_NUM = "embroid_num";

    public static final String BEAUTY_ID = "beauty_id";
    public static final String BEAUTY_NAME = "beauty_name";


    public static void uploadSnapshot(GamePlayer player) {

        try {
            if (!DataAnalyticsMgr.openDataAnalytics()) return;

            DefaultEventTraceAction action = new DefaultEventTraceAction(EMBROID_ROOM, player);

            ColdRoomModule coldRoomModule = player.getModule(ColdRoomModule.class);

            List<Integer> beautyList = new ArrayList<>();
            for (Map.Entry<Integer, UserColdRoomSite> siteEntry : coldRoomModule.getUserColdRoomSiteMap().entrySet()) {
                UserColdRoomSite site = siteEntry.getValue();
                if (site.getBeautyId() > 0) {
                    beautyList.add(site.getBeautyId());
                }
            }
            //上限
            action.build(EMBROID_MAX, coldRoomModule.getUserColdRoomSiteMap().size());
            action.build(EMBROID_NUM, beautyList.size());
            action.build(EMBROID_BEAUTY, beautyList);

            action.trace();
        } catch (Exception e) {
            DataAnalyticsMgr.getLogger().error(" error ", e);
        }

    }
}
